home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-14 | 3.3 KB | 114 lines | [TEXT/KAHL] |
- /******************************************************************************
- CSelectionRect.c
-
- The SelectionRect Class
-
- SUPERCLASS = CPaintTask
-
- Copyright © 1989 Symantec Corporation. All rights reserved.
-
- ******************************************************************************/
-
- #include "Global.h"
- #include "TBUtilities.h"
- #include "CSelectionRect.h"
-
- /*** Global Variables ***/
-
- extern RgnHandle gUtilRgn; /* Utility region */
-
-
- /**** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ****/
-
-
- /******************************************************************************
- CSelectionRect
-
- Initialize a SelectionRect object. There is no task name for a
- selection, since selecting is not undoable.
- ******************************************************************************/
-
- CSelectionRect::CSelectionRect(CPaintPane *aPaintPane,CBitMap *aPainting)
- : CPaintTask(NOTHING, aPaintPane, aPainting)
- {}
-
-
- /******************************************************************************
- KeepTracking
- ******************************************************************************/
-
- void CSelectionRect::KeepTracking(
- LongPt *currPt,
- LongPt *prevPt,
- LongPt *startPt)
- {
- LongRect currRect;
- LongRect prevRect;
- RgnHandle prevRgn;
- RgnHandle dRgn;
- RgnHandle oldVis;
-
- oldVis = NewRgn(); /* Save current visible region in */
- CopyRgn(qd.thePort->visRgn, oldVis); /* case we autoscroll */
-
- if (itsPaintPane->AutoScroll(currPt) || !EqualLongPt(currPt, prevPt)) {
- itsPaintPane->GetFrame(&currRect);
- PinInRect(&currRect, currPt);
- /* Get current and previous */
- /* selection rectangles */
- Pt2LongRect( startPt, currPt, &currRect);
- Pt2LongRect( startPt, prevPt, &prevRect);
-
- /* Here we do a lot of work to */
- /* prevent flashing of the */
- /* selection rectangle */
-
- prevRgn = NewRgn(); /* Construct region consisting of a */
- dRgn = NewRgn(); /* one pixel thick outline of */
- LRectRgn(gUtilRgn, &currRect); /* the current selection rect */
- CopyRgn(gUtilRgn, dRgn);
- InsetRgn(dRgn, 1, 1);
- DiffRgn(gUtilRgn, dRgn, gUtilRgn);
-
- LRectRgn(prevRgn, &prevRect); /* Construct region consisting of a */
- CopyRgn(prevRgn, dRgn); /* one pixel thick outline of */
- InsetRgn(dRgn, 1, 1); /* the previous selection rect */
- DiffRgn(prevRgn, dRgn, prevRgn);
- SectRgn(prevRgn, oldVis, prevRgn);
-
- /* Get region which includes only */
- /* those pixels that are NOT in */
- /* both regions */
- XorRgn(gUtilRgn, prevRgn, gUtilRgn);
- DisposeRgn(prevRgn);
- DisposeRgn(dRgn);
-
- PenMode(patXor); /* Paint this new region in gray in */
- PenPat(&qd.gray); /* Xor mode so pixels are flipped */
- PaintRgn(gUtilRgn);
- }
- DisposeRgn(oldVis);
- }
-
-
- /******************************************************************************
- EndTracking
- ******************************************************************************/
-
- void CSelectionRect::EndTracking(
- LongPt *currPt,
- LongPt *prevPt,
- LongPt *startPt)
- {
- LongRect currRect;
- LongRect prevRect;
-
- KeepTracking(currPt, prevPt, startPt);
-
- /* Set the selection rectangle for */
- /* the PaintPane */
- Pt2LongRect( startPt, currPt, &currRect);
- itsPaintPane->selRect = currRect;
- }
-
-